<template>
  <!-- 登录 -->
  <div class="login_container">

    <!-- 趣事 -->
    <div>
    </div>
    <!-- 登录区域 -->
    <div class="login_box">

      <!-- 头像  -->
      <div class="avatar_box">
        <img src="../assets/img/tx36039.gif"/>

      </div>
      <!-- 表单 -->


      <el-form :model="LoginForm" :rules="LoginFormRules" ref="LoginForm" label-width="100px" class="demo-ruleForm">
        <el-form-item label="账  号" prop="username">
          <el-input v-model="LoginForm.username" prefix-icon="el-icon-user" placeholder="请输入账号"></el-input>
        </el-form-item>
        <el-form-item label="密  码" prop="password">
          <el-input v-model="LoginForm.password" prefix-icon="el-icon-lock" placeholder="请输入密码"></el-input>
        </el-form-item>
        <el-form-item label="验证码" prop="yzm">
          <div class="yzm-in">
            <el-input v-model="LoginForm.yzm" prefix-icon="el-icon-warning-outline" placeholder="请输入验证码"></el-input>
            <img class="yzm-tp" src="../assets/img/msFXK1.gif"/>
          </div>
        </el-form-item>

        <el-form-item class="form-item">

          <el-button type="primary" @click="submitForm('LoginForm')">立即登录</el-button>
          <el-button @click="resetForm('LoginForm')">重置</el-button>
        </el-form-item>

      </el-form>
      <!--  -->

    </div>

    <div></div>

  </div>
</template>

<script>
  export default {
    name: 'Login',
    data () {
      return {
        LoginForm: {
          username: '',
          password: '',
          yzm: ''
        },
        LoginFormRules: {
          username: [
            {
              required: true,
              message: '请输入账号',
              trigger: 'blur'
            },
            {
              min: 3,
              max: 15,
              message: '长度在 3 到 15 个字符',
              trigger: 'blur'
            }
          ],
          password: [
            {
              required: true,
              message: '请输入密码',
              trigger: 'blur'
            },
            {
              min: 3,
              max: 15,
              message: '长度在 3 到 15 个字符',
              trigger: 'blur'
            }
          ],
          yzm: [
            {
              required: true,
              message: '请输入验证码',
              trigger: 'blur'
            }
          ]
        }
      }
    },
    methods: {
      submitForm (formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.$router.push("/main")
          } else {
            console.log('error submit!!')
            return false
          }
        })
      },
      resetForm (formName) {
        this.$refs[formName].resetFields()
      }
    }
  }
</script>

<style lang="less" scoped>
  .login_container {
    height: 100%;
    background-color: coral;
    display: flex;
    justify-content: space-between;
    align-items: center;
    top: 200px;
  }

  .login_box {
    width: 460px;
    height: 380px;
    background-color: #eee9e9;
    border: 1px solid #3c3f41;

    .avatar_box {
      width: 150px;
      height: 150px;
      background-color: #EEEEEE;
      border-radius: 50%;
      margin: -65px auto;

      img {
        width: 100%;
        height: 100%;
        border-radius: 50%;
        background-color: coral;
      }

    }
    .demo-ruleForm {
      padding-top: 100px;
      width: 440px;
      height: 100px;
      margin-left: -15px;

      .form-item {
        display: flex;
        justify-content: flex-end;

      }
    }
    .yzm-in {
      display: flex;
      justify-content: space-between;
    }

    .yzm-tp {
      width: 100px;
      height: 39px;
      border-radius: 5px 0;
    }
  }

</style>
